<?php
/**
 * 
 * 抓攻略
 * @author yangchao
 * @since 2012-03-19
 */
if (!file_exists("../SINASRV_CONFIG")) {
	echo "Read the sinasrv config error!\n";
//	exit();
} else {
   $array_config = parse_ini_file("../SINASRV_CONFIG", true); var_dump($array_config);
   
   $_SERVER = array_merge($_SERVER, $array_config); 
}

/*ini_set("display_errors",ture);
error_reporting(E_ALL);*/

define("CRON_NAME","update_gonglue");//cro名称，要求唯一
set_time_limit(0);
$_GET["db_debug"] = true;
$_GET["no_pref_debug"] = true;
$_GET["api_debug"] = true;

//15分钟一次,执行1000条
define("PCOUNT",10);//每次处理多少mid
define("MAX_PAGE",1000); //定义每个进程处理最大的页数
define("TOTAL_PROCESS",1);//添加新进程需要更新这个配置
define("NOW_PROCESS",$argv[1] ? $argv[1] : 0);//当前进程ID=0 可以申请如下php xxx 1
define("CRON_START_TIME",time());



include_once($_SERVER['DOCUMENT_ROOT'] ."/include/user/inc.php");
include_once($_SERVER['DOCUMENT_ROOT'] ."/include/tucao/inc.php");
include_once($_SERVER['DOCUMENT_ROOT'] ."/include/mblog/inc.php");
include_once($_SERVER['DOCUMENT_ROOT'] ."/include/gonglue/inc.php");

$file_name = "start_id_update";
$id = intval(file_get_contents($file_name));

$sql ="select content,id  from gonglue where  id > $id order by id limit 1000";
$db_base = new db_base();
$list = $db_base->select($sql);



foreach($list as $value)
{
	$content_type = 0;
	$content = $value["content"];
	if(preg_match("/src=['\"\s]?http[\S]+swf/i",$content))
	{
		$content_type = 1;
	}
	if(preg_match("/src=['\"\s]?http[\S]+\/player.html/i",$content))
	{
		$content_type = 1;
	}
	$sql ="update gonglue set content_type = $content_type where id = {$value["id"]} ";
	$db_base->query($sql);
	file_put_contents($file_name,$value["id"]);
}
	
	
